package com.example.demo.service.impl;

import com.example.demo.entity.TbVacation;
import com.example.demo.entity.dto.QueryVacation;
import com.example.demo.entity.dto.VacationDto;
import com.example.demo.mapper.TbVacationMapper;
import com.example.demo.service.TbVacationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author qjt
 * @since 2022-10-09
 */
@Service
public class TbVacationServiceImpl extends ServiceImpl<TbVacationMapper, TbVacation> implements TbVacationService {

    @Autowired
    TbVacationMapper tbVacationMapper;

    /**
     * 员工只能查看自己的请假条
     * @param queryVacation
     * @param roleId
     * @return
     */
    @Override
    public PageInfo<VacationDto> queryByPageAndCondition(QueryVacation queryVacation, Integer roleId) {
        //查询所有
        Page<VacationDto> page = PageHelper.startPage(queryVacation.getCurrentPage(), queryVacation.getPageSize());
        List<TbVacation> tbVacations = tbVacationMapper.selectAllByCondition(queryVacation);

        System.out.println(tbVacations);


        PageInfo<VacationDto> vacationDtoPageInfo = page.toPageInfo();



        return vacationDtoPageInfo;
//        return null;
    }
}
